﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace LCQ.QueryBuilder
{

    [StructLayout(LayoutKind.Sequential)]
    public struct WhereClause
    {
        private string m_FieldName;
        private Comparison m_ComparisonOperator;
        private object m_Value;
        internal List<SubClause> SubClauses;
        public string FieldName
        {
            get
            {
                return this.m_FieldName;
            }
            set
            {
                this.m_FieldName = value;
            }
        }
        public Comparison ComparisonOperator
        {
            get
            {
                return this.m_ComparisonOperator;
            }
            set
            {
                this.m_ComparisonOperator = value;
            }
        }
        public object Value
        {
            get
            {
                return this.m_Value;
            }
            set
            {
                this.m_Value = value;
            }
        }
        public WhereClause(string field, Comparison firstCompareOperator, object firstCompareValue)
        {
            this.m_FieldName = field;
            this.m_ComparisonOperator = firstCompareOperator;
            this.m_Value = firstCompareValue;
            this.SubClauses = new List<SubClause>();
        }

        public void AddClause(LogicOperator logic, Comparison compareOperator, object compareValue)
        {
            SubClause item = new SubClause(logic, compareOperator, compareValue);
            this.SubClauses.Add(item);
        }
        [StructLayout(LayoutKind.Sequential)]
        internal struct SubClause
        {
            public LogicOperator LogicOperator;
            public Comparison ComparisonOperator;
            public object Value;
            public SubClause(LogicOperator logic, Comparison compareOperator, object compareValue)
            {
                this.LogicOperator = logic;
                this.ComparisonOperator = compareOperator;
                this.Value = compareValue;
            }
        }
    }
}
